{% extends 'airshow/base.html' %}
{% load static %}

{% block title %}观众信息管理 - 珠海航展数据管理系统{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="card">
        <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
            <h4 class="mb-0">观众信息管理</h4>
            <div>
                <a href="{% url 'airshow:add_data' table='audienceinfo' %}" class="btn btn-success">
                    <i class="fas fa-plus"></i> 添加观众
                </a>
            </div>
        </div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-striped table-hover">
                    <thead>
                        <tr>
                            <th>姓名</th>
                            <th>电话</th>
                            <th>备注</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for audience in audiences %}
                        <tr>
                            <td>{{ audience.name }}</td>
                            <td>{{ audience.tel }}</td>
                            <td>{{ audience.note }}</td>
                            <td>
                                <div class="btn-group">
                                    <a href="{% url 'airshow:edit_data' table='audienceinfo' pk=audience.id %}" 
                                       class="btn btn-sm btn-primary">
                                        <i class="fas fa-edit"></i> 编辑
                                    </a>
                                    <a href="{% url 'airshow:delete_data' table='audienceinfo' pk=audience.id %}" 
                                       class="btn btn-sm btn-danger">
                                        <i class="fas fa-trash"></i> 删除
                                    </a>
                                </div>
                            </td>
                        </tr>
                        {% empty %}
                        <tr>
                            <td colspan="4" class="text-center">暂无观众信息</td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
            
            {% if is_paginated %}
            <nav aria-label="Page navigation" class="mt-4">
                <ul class="pagination justify-content-center">
                    {% if page_obj.has_previous %}
                    <li class="page-item">
                        <a class="page-link" href="?page={{ page_obj.previous_page_number }}">上一页</a>
                    </li>
                    {% endif %}
                    
                    {% for num in page_obj.paginator.page_range %}
                    <li class="page-item {% if page_obj.number == num %}active{% endif %}">
                        <a class="page-link" href="?page={{ num }}">{{ num }}</a>
                    </li>
                    {% endfor %}
                    
                    {% if page_obj.has_next %}
                    <li class="page-item">
                        <a class="page-link" href="?page={{ page_obj.next_page_number }}">下一页</a>
                    </li>
                    {% endif %}
                </ul>
            </nav>
            {% endif %}
            
            <div class="mt-3 text-muted">
                共 {{ total_count }} 条记录
            </div>
        </div>
    </div>
</div>
{% endblock %} 